package excercise.Page28;

import java.util.Random;
import java.util.Scanner;

/**
 * @Author: Miyako
 * @Date: 2024-07-15-9:01
 * @Description: 随机生成一个图形，并根据你输入的边长值，计算出他的面积与周长
 */
public class PrintPattern {
    static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        Random rand = new Random();
        int r = rand.nextInt(4);
        getShape(r);
    }




    static void getShape(int r) {

        switch (r) {
            case 0:
                System.out.println("输入圆的半径");
                Circle R1 = new Circle(sc.nextDouble());
                R1.print();
                System.out.println("圆的面积为：" + R1.area());
                System.out.println("圆的周长为：" + R1.perimeter());
                return;
            case 1:
                System.out.println("输入矩形的宽和长");
                double x = sc.nextDouble();
                double y = sc.nextDouble();
                Rectangle rec1 = new Rectangle(x, y);
                rec1.print();
                System.out.println("矩形的面积为：" + rec1.area());
                System.out.println("矩形的周长为：" + rec1.perimeter());
                return;
            case 2:
                System.out.println("输入正方形的边长");
                x = sc.nextDouble();
                Square sq1 = new Square(x);
                sq1.print();
                System.out.println("正方形的面积为：" + sq1.area());
                System.out.println("正方形的周长为：" + sq1.perimeter());
                return;
            case 3:
                System.out.println("输入等腰直角三角形的边长");
                x = sc.nextDouble();
                Triangle tr1 = new Triangle(x);
                tr1.print();
                System.out.println("三角形的面积为：" + tr1.area());
                System.out.println("三角形的周长为：" + tr1.perimeter());
        }
    }
}
